﻿using AbpApplication_Module.Model;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.EntityFrameworkCore;

namespace AbpApplication_Module.DBContext
{
    [ConnectionStringName("ProductImage")]
    public class ProductImageDbContext : AbpDbContext<ProductImageDbContext>
    {
        public ProductImageDbContext(DbContextOptions<ProductImageDbContext> options) : base(options)
        {

        }

        ///// <summary>
        ///// 配置日志是否显示
        ///// </summary>
        ///// <param name="optionsBuilder"></param>
        //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        //{
        //    //optionsBuilder.UseLoggerFactory(null);
        //    base.OnConfiguring(optionsBuilder);
        //}

        public DbSet<ProductImage> productImages { get; set; }

        /// <summary>
        /// 配置商品图片模型
        /// </summary>
        public DbSet<ProductImageOrder> ProductImageOrder { set; get; }

        /// <summary>
        /// 权限
        /// </summary>
        public DbSet<PermissionProduct> permissions { set; get; }

        /// <summary>
        /// 
        /// </summary>
        public DbSet<PermissionGrants> permissionGrants { set; get; }

        /// <summary>
        /// 重写方法
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            ////配置应用权限模块
            //模型表前缀
            AbpPermissionManagementDbProperties.DbTablePrefix = "YDT_";
            modelBuilder.ConfigurePermissionManagement();

            //配置应用身份认证模块
            //模型表前缀
            AbpIdentityDbProperties.DbTablePrefix = "YDT_";
            modelBuilder.ConfigureIdentity();

            //配置应用租户模块
            AbpTenantManagementDbProperties.DbTablePrefix = "YDT_";
            modelBuilder.ConfigureTenantManagement();
        }
    }
}
